package com.zlzxm.sorting.globe

import android.content.Context
import android.content.Intent
import android.content.res.Resources
import android.os.Bundle
import android.text.TextUtils
import android.util.TypedValue
import android.widget.TextView

/**
 *
 *CREATE BY zlzxm ON 2022/7/4
 *
 */

val picOne = "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg9.51tietu.net%2Fpic%2F2019-091304%2Ff2vw2etwg3pf2vw2etwg3p.jpg&refer=http%3A%2F%2Fimg9.51tietu.net&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1659598275&t=a370e2f2393b23cff35d61a54d86a8ec";
val picTwo = "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic1.win4000.com%2Fwallpaper%2F2018-07-09%2F5b432e16c1edd.jpg&refer=http%3A%2F%2Fpic1.win4000.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1659598275&t=1acf86f4f2c22efe1e918d05ac1ba9f6"
val picThree = "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.jj20.com%2Fup%2Fallimg%2F1114%2F1110200ZS0%2F2011100ZS0-12-1200.jpg&refer=http%3A%2F%2Fimg.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1659598275&t=3cbbfa7e9562f6c4a3bd91bdd1e2344a";
val picFour = "https://mms2.baidu.com/it/u=3497529909,2737566560&fm=253&app=138&f=JPEG&fmt=auto&q=75?w=496&h=700";



fun <T> Context.startPage(page:Class<T>,bundle : Bundle? = null){

    val intent = Intent(this,page)
    bundle?.let {
        intent.putExtras(it)
    }
    startActivity(intent)

}


fun TextView.checkEmpty(empty:()->Unit,notEmpty:(String)->Unit){

    val content = text.toString().trim()

    if( TextUtils.isEmpty(content)){

        empty()

    }else{

        notEmpty(content)
    }

}

fun TextView.isEmpty():Boolean{


    return TextUtils.isEmpty(text.toString().trim())

}

fun TextView.content(): String {


    return text.toString().trim()

}


fun checkTextEmpty(content:String?, empty:()->Unit,notEmpty:(String)->Unit){

    if( TextUtils.isEmpty(content)){

        empty()

    }else{

        notEmpty(content!!)
    }

}


fun dp2px(dpValue: Float): Int {
    return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,dpValue, Resources.getSystem().displayMetrics)
        .toInt()
}

fun Bundle.addStringParam(key:String,value :String):Bundle{

    putString(key,value)

    return this

}




